package com.chankudo;

import com.chankudo.demo1.PersonService;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

public class demoApp1 {
    public static void main(String[] args) {
        String xmlPath = "demo1.xml";
        //两种常见的xmlApplicationContext
        //ClassPathXmlApplicationContext
        //1.classpath:前缀是不需要的,默认就是指项目的classpath路径下面;
        //2.如果要使用绝对路径,需要加上file:前缀表示这是绝对路径;
        ApplicationContext context = new ClassPathXmlApplicationContext(xmlPath);

        //FileSystemXmlApplicationContext
        //1.没有盘符的是项目工作路径,即项目的根目录;2.有盘符表示的是文件绝对路径.
        //注意：如果要使用classpath路径,需要前缀classpath:
        //ApplicationContext context = new FileSystemXmlApplicationContext("classpath:"+xmlPath);

        PersonService personService = (PersonService)context.getBean("personService");
        personService.addPerson("1");
    }
}
